package com.degon.hsyl.emojidemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.lqr.emoji.EmotionKeyboard;
import com.lqr.emoji.EmotionLayout;
import com.lqr.emoji.IEmotionExtClickListener;
import com.lqr.emoji.IEmotionSelectedListener;

public class SimpleSessionActivity extends AppCompatActivity {

    private LinearLayout mLlContent;
    private EditText mEtContent;
    private ImageView mIvEmo;
    private EmotionLayout mElEmotion;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_session);

        mLlContent = findViewById(R.id.llContent);
        mEtContent = findViewById(R.id.etContent);
        mIvEmo = findViewById(R.id.ivEmo);
        mElEmotion = findViewById(R.id.elEmotion);

        initEmotionKeyboard();

        initViews();

    }

    private void initViews() {

        mElEmotion.attachEditText(mEtContent);

        mElEmotion.setEmotionSelectedListener(new IEmotionSelectedListener() {
            @Override
            public void onEmojiSelected(String key) {

            }

            @Override
            public void onStickerSelected(String categoryName, String stickerName, String stickerBitmapPath) {
                Toast.makeText(getApplicationContext(), stickerBitmapPath, Toast.LENGTH_SHORT).show();
            }
        });
    }

    private void initEmotionKeyboard() {
        EmotionKeyboard mEmotionKeyboard = EmotionKeyboard.with(this);
        mEmotionKeyboard.bindToContent(mLlContent);
        mEmotionKeyboard.bindToEmotionButton(mIvEmo);
        mEmotionKeyboard.bindToEditText(mEtContent);
        mEmotionKeyboard.setEmotionLayout(mElEmotion);
    }
}